<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>
    console.log(1);
    ws = new WebSocket("ws://aoao.doncheng.cn:2346");
    ws.onopen = function (event) {
        alert('连接成功');
        ws.send('tom');
        alert('给服务端发送一个字符串：tom');
    };

    ws.onmessage = function (p1) {
        alert('收到服务端的消息：' + p1.data);
    }
</script>
</body>
</html>